package com.itheima.health.webcontroller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.health.constants.MessageConstant;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.CheckGroup;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.service.OrderSettingService;
import com.itheima.health.service.SetMealService;
import com.sun.org.apache.xpath.internal.operations.String;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 手机端控制层
 */
@RestController
@RequestMapping("/setmeal")
public class WebSetMealController {
    
    @Reference
    private SetMealService setMealService;

    /**
     * 查询所有套餐信息
     * @return
     */
    @RequestMapping("/getSetmeal")
    public Result getSetmeal () {
        try {
            List<Setmeal> list = setMealService.getAllSetMeal();
            return new Result(true, MessageConstant.GET_SETMEAL_LIST_SUCCESS,list);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.GET_SETMEAL_LIST_FAIL);
        }

    }



    @RequestMapping("/findById")
    public Result findById (Integer id) {
        try {
            Setmeal setmeal = setMealService.findById(id);
            return new Result(true, MessageConstant.GET_SETMEAL_LIST_SUCCESS,setmeal);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.GET_SETMEAL_LIST_FAIL);
        }

    }
}
